/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package za.co.pas.business.view.model.list;

import java.util.List;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import za.co.pas.business.constant.Constant;
import za.co.pas.business.data.UserGroups;
import za.co.pas.business.model.ConfDataModel;
import za.co.pas.business.mvc.BusinessMVC;

/**
 *
 * @author alabuschagne
 */
public class UserGroupListModel  implements ListModel
{
    private ConfDataModel configDataModel = (ConfDataModel) Constant.mvc.getModel(BusinessMVC.CONF_DATA_MODEL);

    @Override
    public int getSize()
    {
        if(configDataModel != null)
        {
            List<UserGroups> ct = configDataModel.getUserGroups(false);
            if(ct != null)
            {
                return ct.size();
            }
            else
            {
                return 0;
            }
        }
        else
        {
            return 0;
        }
    }

    @Override
    public Object getElementAt(int index)
    {
        if(configDataModel != null)
        {
            List<UserGroups> ct = configDataModel.getUserGroups(false);
            if((ct != null) && (!ct.isEmpty()))
            {
                return ct.get(index);
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }
    }

    @Override
    public void addListDataListener(ListDataListener l)
    {

    }

    @Override
    public void removeListDataListener(ListDataListener l)
    {

    }
}
